<template>
  <div>
    <li v-for="item in arr" :key="item.id">
      姓名：{{ item.name }} <br />内容：{{ item.content }}
      <button @click="del(item)">删除</button>
    </li>
  </div>
</template>
<script>
import axios from "axios";
export default {
  data() {
    return {
      arr: [],
    };
  },
  mounted() {
    // console.log(this.name);
    axios.get("http://chst.vip:1902/students/getstulist").then((res) => {
    //   console.log(res.data.data);
      this.arr = res.data.data;
    });
  },
  methods: {
    del(item) {
      console.log(item.id);
      axios
        .get("http://chst.vip:1902/students/del", {
          params: {
            id: item.id,
          },
        })
        .then((res) => {
          console.log(res);
          location.reload();
        });
    },
  },
};
</script>
<style scoped>
div {
  width: 800px;
  height: 450px;
  overflow-y: auto;
}
li {
  list-style: none;
  margin: 10px;
  border: 2px solid hotpink;
  position: relative;
  width: 750px;
  height: 50px;
}
button {
  position: absolute;
  bottom: 25%;
  right: 0;
  margin-top: 10px;
  margin-right: 10px;
}
</style>